﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace config3
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ServiceCollection services = new ServiceCollection();
            services.AddScoped<TestWebConfig>();

            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
            //configurationBuilder.Add(new FxConfigSource() { Path = "web.config" });
            configurationBuilder.AddFxConfig();

            IConfigurationRoot configurationRoot = configurationBuilder.Build();
            services.AddOptions().Configure<WebConfig>(e => configurationRoot.Bind(e));

            using (var sp = services.BuildServiceProvider())
            {
                var t = sp.GetRequiredService<TestWebConfig>();
                t.test();
            }
        }
    }
}